package com.etop.learnapp.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ViewFlipper;

import com.etop.learnapp.R;


public class SplashScreen extends Activity {

    private ViewFlipper allFlipper;
    private LinearLayout enter_buttom;
    private TextView text_start;
    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            // TODO Auto-generated method stub
            switch (msg.what) {
                case 1:
                    //切换到主页面
                    allFlipper.setDisplayedChild(1);
                    enter_buttom.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            Intent intent=new Intent(SplashScreen.this,MainActivity.class);
                            startActivity(intent);
                            finish();
                        }
                    });
                    break;
            }
        }
    };
    @Override
    public void onCreate(Bundle savedInstanceState) {
        text_start= (TextView) findViewById(R.id.text_start);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_screens);
        allFlipper = (ViewFlipper) findViewById(R.id.allFlipper);
        enter_buttom = (LinearLayout) findViewById(R.id.enter_buttom);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(1); //给UI主线程发送消息
            }
        }, 3000); //启动等待3秒钟


    }
}
